import 'package:flutter/material.dart';
import 'package:get/get.dart';

// ignore: must_be_immutable
class MyDialog extends Dialog {
  String title;
  Widget content;
  Function()? onClosed;

  MyDialog(
      {super.key,
      required this.title,
      required this.onClosed,
      required this.content});
  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: GestureDetector(
        onTap: () {
          print('什么玩意？？？？？？？？？？？');
          FocusScope.of(context).requestFocus(FocusNode());
        },
        child: Center(
            child: Container(
          height: 500,
          width: 320,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular((8)),
            color: Get.isDarkMode
                ? const Color.fromARGB(164, 0, 0, 0)
                : Colors.white,
          ),
          child: Column(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(10),
                child: Stack(
                  children: <Widget>[
                    Align(
                      alignment: Alignment.center,
                      child: Text(
                        title,
                        style: const TextStyle(fontSize: 18),
                      ),
                    ),
                    Align(
                      alignment: Alignment.centerRight,
                      child: InkWell(
                        onTap: onClosed,
                        child: const Icon(Icons.close),
                      ),
                    )
                  ],
                ),
              ),
              // const Divider(),
              Container(
                padding: const EdgeInsets.all(10),
                width: double.infinity,
                // child: Text(content, textAlign: TextAlign.left),
                child: content,
              )
            ],
          ),
        )),
      ),
    );
  }
}
